const { validateForm } = require('@/utils/validator.js')
const { sm2Encrypt } = require('@/utils/sm2.js')
const cache = require('@/utils/cache.js')
const { getOpenid } = require('@/api/auth.js')

Page({
  data: {
    captchaVisible: false,
    captchaBase64: '',
    captchakey: '',
    canIUse: wx.canIUse('button.open-type.getUserInfo')
  },
  async onLoad() {
    // wx.login({
    //   success: async (res) => {
    //     if (res.code) {
    //       const query = {
    //         code: res.code
    //       }
    //       const {
    //         code,
    //         data
    //       } = await getOpenid(query)
    //     } else {
    //       console.log('登录失败！' + res.errMsg)
    //     }
    //   }
    // })
  },
  bindGetUserInfo (e) {
    console.log(e.detail.userInfo)
  },
  onShow() {
    // token存在，则跳转到首页
    if (cache.getToken()) {
      wx.reLaunch({
        url: '/pages/index/index'
      })
    }
  }
})
